home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / cit.arc / CALLLOG.C next >
Encoding:
C/C++ Source or Header  |  1986-01-22  |  2.7 KB  |  95 lines

  1. /************************************************************************/
  2. /*                calllog.c                */
  3. /*            handles call log of Citadel-86            */
  4. /************************************************************************/
  5.  
  6. #include "ctdl.h"
  7.  
  8. /************************************************************************/
  9. /*                history                 */
  10. /*                                    */
  11. /* 86Jan22 HAW    Set extern var so entire system knows baud.        */
  12. /* 85Dec08 HAW    Put blank lines in file.                */
  13. /* 85Nov?? HAW    Created.                        */
  14. /************************************************************************/
  15.  
  16. /************************************************************************/
  17. /*                Contents                */
  18. /*                                    */
  19. /*    logMessage()        Put out str to file.            */
  20. /************************************************************************/
  21.  
  22. extern struct config cfg;
  23. extern int         byteRate;
  24.  
  25. /************************************************************************/
  26. /*    logMessage() Puts message out.    Also, on date change, and    */
  27. /*             first output of system, insert blank line        */
  28. /************************************************************************/
  29. logMessage(val, str)
  30. char *str;
  31. char val;
  32. {
  33.     struct timeData {
  34.     int y, d, h, m;
  35.     char *month;
  36.     label person;
  37.     };
  38.  
  39.     static int oldDay = 0;
  40.     static char *curBaud;
  41.     static struct timeData lgin;
  42.  
  43.     int        yr, dy, hr, mn;
  44.     char       *mon;
  45.     label      fn;
  46.     FILE       *fopen(), *fd;
  47.  
  48.     if (val == BAUD) {
  49.     if    (strCmp(str, "300" ) == SAMESTRING) byteRate = 30 ;
  50.     else if (strCmp(str, "1200") == SAMESTRING) byteRate = 120;
  51.     else if (strCmp(str, "2400") == SAMESTRING) byteRate = 240;
  52.     else                        byteRate = 0  ;
  53.     }
  54.  
  55.     if (cfg.call_log >= 100) return;
  56.  
  57.     getDate(&yr, &mon, &dy, &hr, &mn);
  58.     switch (val) {
  59.     case BAUD: curBaud      = str;
  60.            lgin.person[0] = 0;
  61.            break;
  62.     case L_IN: lgin.y = yr;
  63.            lgin.d = dy;
  64.            lgin.h = hr;
  65.            lgin.m = mn;
  66.            strCpy(lgin.person, str);
  67.            lgin.month = mon;    break;
  68.     case CARRLOSS:
  69.     case L_OUT:
  70.            if (!lgin.person[0]) {
  71.             curBaud = NULL;
  72.             break;
  73.            }
  74.            sPrintf(fn, "%c:calllog.sys", cfg.call_log + 'a');
  75.            if ((fd = fopen(fn, "a+")) == NULL)
  76.                crashout("Call log error!");
  77.  
  78.            if (oldDay != dy)
  79.                fprintf(fd, "\n");
  80.  
  81.            fprintf(fd, "%-22s: %2d%s%02d %2d:%02d - %2d:%02d (%s)\n",
  82.               lgin.person, lgin.y, lgin.month, lgin.d, lgin.h, lgin.m,
  83.               hr, mn, (curBaud == NULL) ? "sysConsole" : curBaud);
  84.  
  85.            fclose(fd);
  86.  
  87.            lgin.person[0] = 0;
  88.  
  89.            oldDay = dy;
  90.            if (val == CARRLOSS) curBaud = NULL;
  91.            break;
  92.     default: printf("crashout: unknown case in switch statement");
  93.     }
  94. }
  95.